﻿#include "Toolbar.h"

#include <QMainWindow>
#include <QMenu>
#include <QPainter>
#include <QPainterPath>
#include <QBoxLayout>
#include <QGroupBox>
#include <QSpinBox>
#include <QLabel>
#include <QToolTip>
#include <QComboBox>
#include <Qvector>
#include <QList>

ToolBar::ToolBar(char *title,QWidget *parent) : QToolBar(parent)
{
	setWindowTitle(title);
	setObjectName(title);
}

ToolBar::~ToolBar()
{
}

void ToolBar::addSpinBox()
{
	QAction *action;
	_spinBox.push_back(new QSpinBox(this));
	_spinBox.last()->setRange(1,1000000);
	_spinBox.last()->setAlignment(Qt::AlignCenter);
	_spinBox.last()->resize(5,10);
	 action = addWidget(_spinBox.last());
}

void ToolBar::endPart()
{
	this->addSeparator();
}
void ToolBar::addLabel(char* text, QFont *f)
{
	this->addWidget(new QFrame);
	QAction *action;
	_label.push_back(new QLabel(this));
	_label.last()->setFont(*f);
	_label.last()->setText(text);
	_label.last()->setAlignment(Qt::AlignCenter);
	 action = addWidget(_label.last());
}
///////////////////////////////////////////////////////////////////////////
// добавление простого ComboBox
void ToolBar::addComboBox(QStringList *qstr, QFont *f)
{
	QAction *action;
	_comboBox.push_back(new QComboBox(this));
	_comboBox.last()->setFont(*f);
	_comboBox.last()->addItems(*qstr);
	action = addWidget(_comboBox.last());
	this->addSeparator();
}
///////////////////////////////////////////////////////////////////////////
// добавление ComboBox’а с иконкой
void ToolBar::addComboBox(QVector<QIcon> *icon,QStringList *str, QFont *f)
{
	QAction *action;
	_comboBox.push_back(new QComboBox(this));
	_comboBox.last()->setFont(*f);
	QVector<QIcon>::iterator qIt;
	int it_str=0;
	qIt = icon->begin();
	while (qIt!=icon->end())
	{
		_comboBox.last()->addItem( *qIt, str->at(it_str) );
		it_str++;
		qIt++;
	}
	action = addWidget(_comboBox.last());
	this->addSeparator();
}

